package org.mathcloud.math.core.maple.operator.algebra;

//import classes slf4j
import org.mathcloud.math.core.maple.operator.MapleBinaryOperator;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import org.mathcloud.math.core.common.operator.algebra.Divide;


public class MapleDivide extends MapleBinaryOperator implements Divide
{
	@Override
	public void calculate()
	{				
		try {
			if(operand1.getSignature().isMatrix() && operand2.getSignature().isMatrix()) {
				MapleInverse mapleinv = new MapleInverse();
				MapleTimes mapletimes = new MapleTimes();
				mapleinv.setInputParams(operand2);
				mapleinv.calculate();
				mapletimes.setInputParams(operand1, mapleinv.getResult());
				mapletimes.calculate();
				res = mapletimes.getResult();
			}
			else 
				calculate("/", true, logger);
		}
		catch(Exception e) {
			logger.error("Exception:", e);
		}
	}	
	
	final Logger logger = LoggerFactory.getLogger(MapleDivide.class);
}
